/* tslint:disable:no-console */
import {InterfacePosition} from '@/interface/InterfacePosition';
import {ActionContext, ActionTree, Commit, Dispatch, Getter, GetterTree, MutationTree} from 'vuex';
import * as types from '../mutation-types';

export default class PositionStore {
    public static initState: InterfacePosition = {
        name: '',
        position: '',
        latitude: 0,
        longitude: 0,
        type: -1,
        selected: false,
        zoom: 12,
    };
    public static state: InterfacePosition = PositionStore.initState;

    public static mutations: MutationTree<InterfacePosition> = {
        [types.POSITION_UPDATE](state: InterfacePosition | any, position: InterfacePosition) {
            state.name = position.name;
            state.position = position.position;
            state.latitude = position.latitude;
            state.longitude = position.longitude;
            state.type = position.type;
            state.selected = position.selected;
            // state = Object.assign(state, position);
        },
        [types.POSITION_CLEAR](state: InterfacePosition) {
            state = Object.assign(state, PositionStore.initState);
        },
    };

    // private static getters: GetterTree<InterfacePosition, any> = {
    //     getPosition: (state: InterfacePosition) => state,
    // };
}
